var yfmbgl_app = function() {
	var path = Constants.amUrlPath;
	var ractive;
	var default_fz = '结算查询';
	function renderView() {
		ractive = new Ractive({
			el : ".hp-container",
			template : "#main-template",
			onrender: function() {
			},
			oncomplete : function() {
				var _sc_param = {
						pageSize : Constants.page.pagesize,
						currPage : 1
				};
				initTable(_sc_param);
			}
		});

		ractive.on({
			cxbutton : function() {
				var _cx_param = {
						pageSize : Constants.page.pagesize,
						currPage : 1
				};
				var _param = review();
				// 合并查询参数
				var objs = $.extend(_cx_param, _param);
				initTable(objs);
			}
		});
	}

	/**
	 * 获取参数
	 */
	function review() {
		var _param = {};
		if (typeof ractive != "undefined") {
			var param = ractive.get("hzfcx");
			_param.tjsjks = (param.tj_begin_sj.length == 10 ? param.tj_begin_sj + "T00:00:00+08" : param.tj_begin_sj);
			_param.tjsjjs = (param.tj_end_sj.length == 10 ? param.tj_end_sj + "T23:59:59+08" : param.tj_end_sj);
			_param.shsjks = (param.sh_begin_sj.length == 10 ? param.sh_begin_sj + "T00:00:00+08" : param.sh_begin_sj);
			_param.shsjjs = (param.sh_end_sj.length == 10 ? param.sh_end_sj + "T23:59:59+08" : param.sh_end_sj);
			_param.hzfmc = $.trim(param.hzfmc);
			param.hzfmc=$.trim(param.hzfmc);
			ractive.set("hzfcx",param);
		}
	    
	    
	    
		return _param;
	}
	/**
	 * 获取列表数据
	 */
	function initTable(param) {
		
		var _title_hzfmc = "合作方名称";
		var _title_ssdq = "合作方编号";
		var _title_fwfx = "合作方账号";
		var _title_tjsj = "提交时间";
		var _title_shsj = "审核时间";

		
		
	
		var _table_title = [_title_hzfmc,_title_ssdq,_title_fwfx, _title_tjsj, _title_shsj];
		var _col_model = [
				{
					name : 'hzfmc',
					width : 40,
					float :'left'
				},
				{
					name : 'hzfid',
					width : 40
				},
				{
					name : 'zh',
					width : 40
				},
				{
					name : 'creatertime',
					width : 40,
					innerhtml:function(opts){
						if(opts.creatertime){
							return moment(opts.creatertime).format("YYYY-MM-DD HH:mm:ss");
						}else{
							 return "";
						}
					}
				},
				{
					name : 'spsj',
					width : 80,
					innerhtml:function(opts){
						if(opts.spsj){
							return moment(opts.spsj).format("YYYY-MM-DD HH:mm:ss");
						}else{
							 return "";
						}
					}
				}];
		jQuery("#wd-table").wdGrid({
			url:path+'hzfgl/getHzfcxPagination',
			colNames : _table_title,
			colModel : _col_model,
			dataType : "GET",
			submitType : "noForm",
			postData : param,
			pager : "#wd-pager",
			rowList: Constants.page.rowList,
	        pagesize: Constants.page.pagesize
		});
	}
	return {
		init : function() {
			renderView();
		}
	};
}();
$(document).ready(yfmbgl_app.init);